//
//  MemberManagementHeaderView.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/4.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "MemberManagementHeaderView.h"
#import "NSMutableAttributedString+FIDText.h"
#import "MemberModel.h"

@implementation MemberManagementHeaderView
- (void)setMemberModel:(MemberModel *)memberModel
{
    _memberModel = memberModel;
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
    self.nameLabel.attributedText = [string attributeStrings:@[memberModel.nickname,[NSString stringWithFormat:@"  (%@)",memberModel.username]] attributes:@[@[[UIColor whiteColor],fontCommonSize],@[[UIColor grayColor],fontWithSize(14)]]];
    self.iconImageView.image = imageWithName(@"icon_head");

}
- (void)setName:(NSString *)name phone:(NSString *)phone
{
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] init];
    self.nameLabel.attributedText = [string attributeStrings:@[name,[NSString stringWithFormat:@"  (%@)",phone]] attributes:@[@[[UIColor whiteColor],fontCommonSize],@[[UIColor grayColor],fontWithSize(14)]]];
}

- (UIImageView *)iconImageView
{
    if(!_iconImageView)
    {
        UIView *superView = self;
        _iconImageView = [[UIImageView alloc]init];
        [superView addSubview:_iconImageView];
    }
    return _iconImageView;
}
- (UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        UIView *superView = self;
        _nameLabel = [[UILabel alloc]init];
        [superView addSubview:_nameLabel];
    }
    return _nameLabel;
}


- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    UILabel *label =({
        label = [[UILabel alloc] init];
        [superView addSubview:label];
        label.textColor = [UIColor whiteColor];
        label.font = fontWithSize(16);
        label.text = @"管理员";
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(superView.mas_top).with.offset(px1920Height(90));
            make.left.mas_equalTo(superView.mas_left);
        }];
        label;
    });
    
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(label.mas_left);
        make.top.mas_equalTo(label.mas_bottom).with.offset(px1920Height(72));
        make.height.width.mas_equalTo(px1920Height(130));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.iconImageView.mas_centerY);
        make.left.mas_equalTo(self.iconImageView.mas_right).with.offset(px1080Width(60));
        make.right.mas_equalTo(superView.mas_right);
    }];
    
  
    UIButton *addButton = [[UIButton alloc]init];
    [superView addSubview:addButton];
    [addButton setTitle:@"已添加成员" forState:UIControlStateNormal];
    [addButton setImage:imageWithName(@"btn_news_nor") forState:UIControlStateNormal];
    [addButton setTitleColor:rgba(143,157,189,1) forState:UIControlStateNormal];
    [addButton.titleLabel setFont:fontWithSize(17)];
    [addButton layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:10];
    addButton.userInteractionEnabled = NO;

    [addButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left);
        make.bottom.mas_equalTo(superView.mas_bottom).with.offset(-px1920Height(47));
        make.width.mas_equalTo(100);
    }];
}


@end
